package p.jce;

import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;

public class RKeyPairGenerator {

	public static KeyPairGenerator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException {
		return getInstance(algorithm);
	}

	public static KeyPairGenerator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException,
			NoSuchProviderException {
		if ("BC".equals(provider)) {
			try {
				return BC.newInstance("KeyPairGenerator", algorithm);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return KeyPairGenerator.getInstance(algorithm, provider);
	}

	public static KeyPairGenerator getInstance(String algorithm) throws NoSuchAlgorithmException {
		try {
			return getInstance(algorithm, "BC");
		} catch (NoSuchProviderException e) {
			throw new RuntimeException(e);
		}
	}
}
